package com.theydream.qeechain.battle;

import java.util.Observable;
import java.util.Observer;
import java.util.Stack;

import com.theydream.qeechain.R;

public class SkillLogic {
	private static Stack<Integer> list = new Stack<Integer>();
	 
	private static Observable onElementAddedObservable = new Observable(){
		@Override
	public boolean hasChanged(){return true;}
		};
	
	public static void addElementAddedObserver(Observer o)
	{
		onElementAddedObservable.addObserver(o);
	}
	
	public static void deleteElementAddedObserver(Observer o)
	{
		onElementAddedObservable.deleteObserver(o);
	}
	
	public static void deleteElementAddedObservers()
	{
		onElementAddedObservable.deleteObservers();
	}
		
	public static void addElement(int eid)
	{
		list.push(eid);
		onElementAddedObservable.notifyObservers(eid);
	}
	
	public static void removeElement()
	{
		if(!list.empty()){
			list.pop();
			onElementAddedObservable.notifyObservers(null);
		}
	}
	
	
//	public static Integer[] popElements()
//	{
//		Integer[] array = (Integer[]) list.toArray();
//		list.clear();
//		return array;
//
//	}
	
	public static String popElements()	{
		String str = "";
		
		for (Integer element : list)	{
			str += Integer.toString(element);
		}
		list.clear();
		return str;
		
	}
	
	public static Integer[] peekElements()
	{
		return (Integer[]) list.toArray();
	}
	
	/*
	 * public static Skill popSkill()
	{
		SkillDAO.getSkillfromElements(list.toString());
		list.setLength(0);
	}
	*/
	
//	public static Map<String, String> mapViewToElement = new HashMap<String, String>();
	
	public static int getDrawableID(int viewId)
	{
		switch(viewId)
		{
		case R.id.skill1: return R.drawable.sun_s;
		case R.id.skill2: return R.drawable.nature_s;
		case R.id.skill3: return R.drawable.ice_s;
		case R.id.skill4: return R.drawable.fire_s;
		case R.id.skill5: return R.drawable.earth_s;
		}
		
		return -1;
	}
	
	public static int getElementIdFromView(int viewId){
		switch (viewId)	{
		case 2131230758: return 1;
		case 2131230760: return 2;
		case 2131230757: return 3;
		case 2131230759: return 4;
		case 2131230756: return 5;	
		}
		return -1;
	}


}
